<cfif Not IsDefined("session.id")>
		<cflocation url = "/ecada/" addToken = "no">
</cfif>
	
<cfif IsDefined("session.experiment")>
	<cfset experiment = session.experiment>
<cfelse>
	<cflocation url="/ecada/" addToken="No" >
</cfif>

<cfif IsDefined("form.submit")>

<cfelse>
	
	<cfinclude template= "/ecada/header.cfm">
	
	<cfoutput>
		<script type="text/javascript">
			$(document).ready(function(){
			//this function is defined in progressbar.cfm and is included in the header
				setProgressText("Specify Stimuli");
				setProgress(3);
			});
		</script>
	</cfoutput>
	
	<cfquery datasource="exp" name="conditions">
		SELECT *
		FROM conditions
		WHERE expid = #experiment.id#
		ORDER BY id
	</cfquery>
	
	<cfloop query="conditions">
		<cfoutput>

				<fieldset>
					<legend>
							Condition: #HTMLEditFormat(Title)#
					</legend>
			<table>
				<tr>
					<td>
					

							<cfquery datasource="exp" name="stimuli">
								SELECT *
								FROM stim
								WHERE CondID = #id#
								ORDER BY Title Asc
							</cfquery>
							<table>
									
							<cfloop query="stimuli">
								
									<tr>
											<cfquery datasource="exp" name="ImageDetails">
												SELECT *
												FROM filestore
												WHERE id = #FileID#
											</cfquery>
										<td>
											<img style="width: 75px; height: 75px; margin: 0;" src="/ecada/files/#ImageDetails.filepath#/#ImageDetails.filename#" width="75px" height="75px" alt="#ImageDetails.filename#" />
										</td>
									
										<td style="width: 200px;">
											<p>#HTMLEditFormat(Title)#</p>
										</td>
			
									<td>
										<form method="post" action="edit/">
											<input type="hidden" name="EditID" value="#id#"></input>
											<input type="submit" value="Edit Stimuli"></input> 
										</form>
									</td>
									<td>
										<form method="post" action="delete/">
											<input type="hidden" name="DeleteID" value="#id#"></input>
											<input type="submit" value="Delete Stimuli"></input> 
										</form>
									</td>
								</tr>
								
							</cfloop>
							<tr>
								<td>
					<form method="post" action="add/">
						<input type="hidden" name="CondID" value="#id#"></input>
						<button class="ui-state-default ui-corner-all" title="Next" type="submit" value="Add stimuli">
							<div>
								<div style="display: inline-block; margin: 3px;line-height: 16px;"><b>Add stimuli</b></div>
							</div>
						</button>
					</form>
								</td>
								<td>
					
					<form method="post" action="zip/">
						<input type="hidden" name="CondID" value="#id#"></input>
						<button class="ui-state-default ui-corner-all" title="Next" type="submit" value="Add mulitple stimuli">
							<div>
								<div style="display: inline-block; margin: 3px;line-height: 16px;"><b>Add mulitple stimuli</b></div>
							</div>
						</button>
					</form>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			</fieldset>
		</cfoutput>
	</cfloop>
	<cfoutput>
	<div>
		<div style="width: 100%;">
			<div style="width: 10%; float: left;">
				<form method="post" action="./../Step-2">
					<button class="ui-state-default ui-corner-all" title="Back" type="submit" value="Back">
							<div>
								<div style="display: inline-block; margin: 3px;line-height: 16px;"><b>Back</b></div>
							</div>
						</button>

				</form>
			</div >
			<div style="width: 50%; float:left;">
				<form method="post" action="./../Step-4">
					<button class="ui-state-default ui-corner-all" title="Next" type="submit" value="Next">
							<div>
								<div style="display: inline-block; margin: 3px;line-height: 16px;"><b>Next</b></div>
							</div>
						</button>
				</form>
			</div>
		</div>
	</div>
	</cfoutput>
	<cfinclude template= "/ecada/footer.cfm">
	
</cfif>



